﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace RoccaStore.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            this.Error += OnApplicationError;
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            RegisterBundles();
        }

        private void RegisterBundles()
        {
            BundleTable.EnableOptimizations = true;
            var bundles = BundleTable.Bundles;

            // jquery
            bundles.Add(new ScriptBundle(
                "~/bundles/jquery",
                "//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js")
                .Include("~/scripts/jquery-1.8.3.js"));

            // all scripts
            bundles.Add(new ScriptBundle(
                "~/bundles/scripts")
                .Include(
                "~/scripts/jquery.uploadify-3.1.js",
                "~/scripts/main.js",
                "~/scripts/qtip.min.js",
                "~/scripts/modern.js",
                "~/scripts/jquery.tokeninput.js",
                "~/scripts/jquery.blockUI.js"));

            bundles.Add(new ScriptBundle(
                "~/bundles/jquery-validate",
                "//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.10.0/jquery.validate.min.js")
                .Include("~/scripts/jquery.validate.js"));

            bundles.Add(new ScriptBundle(
                "~/bundles/ie")
                .Include("~/scripts/json2.js"));

            // all css
            bundles.Add(
                new StyleBundle("~/bundles/css")
                .IncludeDirectory("~/content/styles/", "*.css"));
        }

        public override void Init()
        {
            base.Init();
        }

        void OnApplicationError(object sender, EventArgs e)
        {
            
        }
    }
}